package com.agsmobi.digitapp;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Window;
import android.view.WindowManager;

public class BaseActivity extends Activity{
	
	int screenWidth;
	int screenHeight;
	protected static final int VERTICAL = 0;
	protected static final int HORIZONTAL = 1;
	protected ProgressDialog dialog = null;
	protected static int imageDigit[] = new int[]{
		R.drawable.digit00,R.drawable.digit01,R.drawable.digit02,R.drawable.digit03,R.drawable.digit04,
		R.drawable.digit05,R.drawable.digit06,R.drawable.digit07,R.drawable.digit08,R.drawable.digit09,
		R.drawable.digit10,R.drawable.digit11,R.drawable.digit12,R.drawable.digit13,R.drawable.digit14,
		R.drawable.digit15,R.drawable.digit16,R.drawable.digit17,R.drawable.digit18,R.drawable.digit19,
		R.drawable.digit20,R.drawable.digit21,R.drawable.digit22,R.drawable.digit23,R.drawable.digit24,
		R.drawable.digit25,R.drawable.digit26,R.drawable.digit27,R.drawable.digit28,R.drawable.digit29,
		R.drawable.digit30,R.drawable.digit31,R.drawable.digit32,R.drawable.digit33,R.drawable.digit34,
		R.drawable.digit35,R.drawable.digit36,R.drawable.digit37,R.drawable.digit38,R.drawable.digit39,
		R.drawable.digit40,R.drawable.digit41,R.drawable.digit42,R.drawable.digit43,R.drawable.digit44,
		R.drawable.digit45,R.drawable.digit46,R.drawable.digit47,R.drawable.digit48,R.drawable.digit49,
		R.drawable.digit50,R.drawable.digit51,R.drawable.digit52,R.drawable.digit53,R.drawable.digit54,
		R.drawable.digit55,R.drawable.digit56,R.drawable.digit57,R.drawable.digit58,R.drawable.digit59,
		R.drawable.digit60,R.drawable.digit61,R.drawable.digit62,R.drawable.digit63,R.drawable.digit64,
		R.drawable.digit65,R.drawable.digit66,R.drawable.digit67,R.drawable.digit68,R.drawable.digit69,
		R.drawable.digit70,R.drawable.digit71,R.drawable.digit72,R.drawable.digit73,R.drawable.digit74,
		R.drawable.digit75,R.drawable.digit76,R.drawable.digit77,R.drawable.digit78,R.drawable.digit79,
		R.drawable.digit80,R.drawable.digit81,R.drawable.digit82,R.drawable.digit83,R.drawable.digit84,
		R.drawable.digit85,R.drawable.digit86,R.drawable.digit87,R.drawable.digit88,R.drawable.digit89,
		R.drawable.digit90,R.drawable.digit91,R.drawable.digit92,R.drawable.digit93,R.drawable.digit94,
		R.drawable.digit95,R.drawable.digit96,R.drawable.digit97,R.drawable.digit98,R.drawable.digit99};
	
	protected static int imageScore[] = new int[]{
		R.drawable.scoredigit0,R.drawable.scoredigit1,R.drawable.scoredigit2,R.drawable.scoredigit3,
		R.drawable.scoredigit4,R.drawable.scoredigit5,R.drawable.scoredigit6,R.drawable.scoredigit7,
		R.drawable.scoredigit8,R.drawable.scoredigit9
	};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}

	/*
	 * loadControl
	 */
	protected void loadControl(){
		DisplayMetrics metrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(metrics);
		screenWidth = metrics.widthPixels;
		screenHeight = metrics.heightPixels;
	}
	/*
	 * loadData
	 */
	protected void loadData(){
		
	}
	
	/*
	 * startTask
	 */
	protected void startTask(Runnable run){
		Thread thread = new Thread(run);
		thread.start();
	}
	
	/*
	 * showProgressBar
	 */
	public void showProgressBar(){
		if (dialog == null || !dialog.isShowing()) {
			dialog = ProgressDialog.show(this,getString(R.string.app_name), getString(R.string.title_loading));
		}
	}
	/*
	 * showProgressBar
	 */
	public void showProgressBar(Context context){
		if (dialog == null || !dialog.isShowing()) {
			dialog = ProgressDialog.show(context,getString(R.string.app_name), getString(R.string.title_loading));
		}
	}
	/*
	 * showProgressBar
	 */
	public void showProgressBar(Context context,String titleLoading){
		if (dialog == null || !dialog.isShowing()) {
			dialog = ProgressDialog.show(context,getString(R.string.app_name),titleLoading);
		}
	}
	/*
	 * closeProgressBar
	 */
	public void closeProgressBar(){
		if (dialog != null) {
			dialog.dismiss();
		}	
	}
	
	/*
	 * showMessage
	 */
	public void showMessage(String message, boolean isDisplayTitle){
	
		AlertDialog.Builder build = new AlertDialog.Builder(this);
		if (isDisplayTitle) {
			build.setTitle(getString(R.string.app_name));
		}
		build.setMessage(message);
		build.setPositiveButton(getString(R.string.title_ok), null);
		build.show();
	
	}
}













